//
//  XueLiDetViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/9/15.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "XueLiDetViewController.h"

@interface XueLiDetViewController ()<UITableViewDelegate,UITableViewDataSource>{
    NSArray *arrtit;
    NSMutableArray *arrdets;
}

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation XueLiDetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = COLOR_RGB(242, 242, 242, 1);
    [self showNav:@"学历"];
    arrtit = @[@"学历",@"学历类型",@"入学日期",@"毕业结论",@"毕业日期",@"专业",@"学校"];
    arrdets = [NSMutableArray array];
    [self loadData];
    
    
}

- (void)loadUI{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, 44*arrtit.count-2) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
}
#pragma -mark UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arrtit.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
    }
    cell.textLabel.text = arrtit[indexPath.row];
    cell.detailTextLabel.text = arrdets[indexPath.row];
    
    return cell;
}
//学历详情
- (void)loadData{
    [SVProgressHUD show];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    NSString *str = [NSString stringWithFormat:@"%@890d69e502d1d37a9e84335ccefece57",[user objectForKey:@"token2"]];
    NSString *token = [LCMD5Tool md5:str];
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:token forKey:@"verifyToken"];
    [parmas setObject:[user objectForKey:@"userid"] forKey:@"userid"];
    
    NSString *url = [NSString stringWithFormat:@"%@/App/Usercenter/academicDetails",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"学历详情res:%@",responseObject);
        NSDictionary *dic = [responseObject objectForKey:@"content"];
        NSString *education = [dic objectForKey:@"education"];
        NSString *degreetype = [dic objectForKey:@"degreetype"];
        NSString *gradresult = [dic objectForKey:@"gradresult"];
        NSString *major = [dic objectForKey:@"major"];
        NSString *school = [dic objectForKey:@"school"];
        NSString *graddate = [dic objectForKey:@"graddate"];
        NSString *enrolldate = [dic objectForKey:@"enrolldate"];
        
        [arrdets addObject:education];
        [arrdets addObject:degreetype];
        [arrdets addObject:enrolldate];
        [arrdets addObject:gradresult];
        [arrdets addObject:graddate];
        [arrdets addObject:major];
        [arrdets addObject:school];
        
        
        [self loadUI];
//        [_tableView reloadData];
        [SVProgressHUD dismiss];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD dismiss];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
